<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by CodeTlan.
 * User: Ing. Miguel Salas
 * Date: 3/25/12
 * Time: 1:18 AM
 */
class Permisos extends CT_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model("permiso", "dao");
    }

    function find()
    {
        $datos = array(
            'rol_session' => $this->session->getRol(),
            'rol_k' => $this->input->post("rol_k")
        );
        echo json_encode(array('success' => true, 'data' => $this->dao->find($datos)));
    }

    function edit()
    {

        if (!$this->input->post("permiso")) {
            echo $this->_edit(array('estatus' => 0), array('permiso_k' => $this->input->post('permiso_k')));
        }
        else {
            $data['modulo_k'] = $this->input->post('modulo_k');
            $data['accion_k'] = $this->input->post('accion_k');
            $data['rol_k'] = $this->input->post('rol_k');
            $data['activo'] = 1;
            $data['estatus'] = 1;
            echo $this->_add($data);
        }
    }
}
